package com.echo.register.order.receiver;

import com.echo.register.common.constant.MqConst;
import com.echo.register.order.service.OrderService;
import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @ClassName: OrderReceiver
 * @Package: com.echo.register.order.receiver
 * @Description: 消息监听器
 * @Author 谢同学
 * @Create 2024/1/11 16:54
 * @Version 1.0
 */
@Slf4j
@Component
public class OrderReceiver {
    @Autowired
    private OrderService orderService;
    @RabbitListener(bindings = @QueueBinding(
           exchange = @Exchange(MqConst.EXCHANGE_DIRECT_TASK),
            value = @Queue(name = MqConst.QUEUE_TASK_8,durable = "true"),
            key = MqConst.ROUTING_TASK_8
    ))
    public void receive(Message message, Channel channel){
        log.info("【订单服务-接收每天定时消息。。。。】");
        orderService.patientTips();
    }
}
